import global from 'global';
import {bladeGoodsDefinitions} from '../../../@types/api/def-blade-goods';
import {searchDefinitions} from '../../../@types/api/def-search';
// import ajaxService from '../../../utils/ajaxService';

export type ProductData = searchDefinitions['JztGoodsInfo'];

export type ProductListPartData = {
	list: ProductData[];
	cateData: bladeGoodsDefinitions['MultiCategoryVO'][];
	pageNo: string;
	totalPage: number;
	totalCount: number;
	name: string;
	id: string;
};

type RouteParams = {
	name;
	id;
	pageNo;
};

// 在此加载页面所需数据
async function promiseWithError(p) {
	try {
		const res = await p;
		return res;
	} catch (e) {
		return {};
	}
}
// export async function fetchProductListData(routeParams: RouteParams, props): Promise<ProductListPartData> {
// 	const {name, id} = routeParams;
// 	const pageNo = (global.isPc && routeParams.pageNo) || '1';
// 	const categoryIds = id ? [id] : undefined;
// 	const {supplierId, contactIds} = props?.companyInfo || {};
// 	const limitPro = global.isPc ? 16 : 10;
// 	const [res, res2] = await Promise.all([ajaxService.searchGoods({limit: limitPro, page: pageNo - 1, domain: global.apiDomain, categoryIds}), ajaxService.searchProductCate({supplierConcactId: contactIds, supplierId: supplierId})]);
// 	return {
// 		list: res?.data?.items,
// 		pageNo,
// 		totalPage: res?.data?.totalPage || 0,
// 		totalCount: res?.data?.totalCount || 0,
// 		name,
// 		id,
// 		cateData: res2?.data || [],
// 	};
// }
